<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <a href="#/test">test</a>
    <a href="#/first">first</a>

    <component v-bind:is="flag"></component>
  </div>
  <script src="./vue.js"></script>
  <script>
    Vue.component('test', {
      template: '<div>我是test</div>'
    })
    Vue.component('first', {
      template: '<div>我是first</div>'
    })

    const vm = new Vue({
      el: '#app',
      data: {
        flag: 'first'
      }
    })

    window.onhashchange = function() {
      if( location.hash.slice(1) === '/test' ) {
        vm.flag = 'test'
      } else if(location.hash.slice(1) === '/first' ) {
        vm.flag = 'first'
      }
    }

  </script>
</body>
</html>